package com.danikula.videocache.logger

import android.util.Log
import java.util.*

class LoggerFactory(tag: String) : Logger {

    private var tag: String = "视频缓存-$tag"

    companion object {
        @JvmStatic
        fun getLogger(tag: String): LoggerFactory {
            return LoggerFactory(tag)
        }
    }

    override fun warn(msg: String) {
        Log.w(tag, msg)
    }

    override fun warn(msg: String, e: Exception) {
        Log.w(tag, "$msg Exception:$e")
    }

    override fun warn(msg: String, add: String) {
        val str = msg.replaceFirst("{}", add)
        Log.w(tag, str)
    }

    override fun warn(msg: String, date: Date, path: String) {
        val str = msg.replaceFirst("{}", date.toString())
        Log.w(tag, str.replaceFirst("{}", path))
    }

    override fun info(msg: String) {
        Log.i(tag, msg)
    }

    override fun error(msg: String) {
        Log.e(tag, msg)
    }

    override fun error(msg: String, e: Exception) {
        Log.e(tag, "$msg Exception:$e")
    }

    override fun error(msg: String, e: Throwable) {
        Log.e(tag, "$msg Throwable:$e")
    }

    override fun debug(msg: String) {
        Log.d(tag, msg)
    }
}